<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*"
    pageEncoding="utf-8"%>
<%@page import="com.qlujavateam.methods.Dictionary"%>
<%@ include file="include.jsp" %>
<%
//声明
String xyname=""; //学院
String xiname=""; //系
String zyname=""; //专业
String njname=""; //年级
String bjname=""; //班级
%> 
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<title>二维码签到系统管理端</title>

<!-- 报表引入的框架 -->	
<script src="${CTX_PATH}/js/dhtmlxchart.js" type="text/javascript"></script>
<link rel="STYLESHEET" type="text/css" href="${CTX_PATH}/css/dhtmlxchart.css">
</head>
<body background="https://i.loli.net/2021/06/20/dZBxAe7RCnkq6sJ.jpg" style=" background-repeat:no-repeat ;background-size:100% 100%;
background-attachment: fixed;">

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
					<ul >
						<li>
							<p align="right"><a href="${CTX_PATH}/index.jsp"><span class="glyphicon glyphicon-log-out" > </span> 安全退出</a></p>
						</li>
					</ul>
				</div>	
<div  style="margin-top: 50px;">
	<div class="container">
		<h1 align="center">齐鲁工业大学二维码签到程序</h1>
	</div>
</div>
<div class="container" style="margin-bottom:20px">
	<div class="col-lg-3">
		<div class="list-group " >
			<!--<a href="#" id="a_kq" class="list-group-item active">数据统计 </a>-->
			<a href="#" class="list-group-item">教师管理</a>
			<a href="#" id="a_set" class="list-group-item ">设置</a>
		</div>
	</div>
	
	<div class="col-lg-9" style="background-color: white; min-height: 350px; padding-top: 10px;">

		<div id="div_teacher_manager">
					
			<ul class="nav nav-tabs" role="tablist">
				<li role="presentation" class="active">
						<a href="#home" aria-controls="home" role="tab" data-toggle="tab">教师管理</a>
				</li>

			</ul>
			<div class="tab-content">
				<div role="tabpanel" class="tab-pane active" id="home" style="padding: 10px;">

							<!--显示老师信息 start -->
					<table id="teacher_show" class="table table-striped table-bordered table-hover">
							<tr>
								<td>编号</td>
								<td>姓名</td>
								<td>电话</td>
								<td>性别</td>
							</tr>

						</table>
							<!--显示老师信息 end -->

				</div>
				<div role="tabpanel" class="tab-pane" id="profile">
				</div>
			</div>
		</div>
		<div id="div_set" style="">
					<!-- Nav tabs -->
					<ul class="nav nav-tabs" role="tablist">
						<li role="presentation" class="active">
							<a href="#sjzd" aria-controls="home" role="tab" data-toggle="tab">班级管理</a><!--数据字典(专业班级)-->
						</li>
					</ul>
					<!-- Tab panes -->
					<div class="tab-content">
						<div role="tabpanel" class="tab-pane active" id="sjzd">
							<table class=" table table-striped table-bordered table-condensed">
								<tr>
									<td>学院</td>
									<td>系名称</td>
									<td>专业</td>
									<td>年级</td>
									<td>班级</td>
								</tr>
									<!-- 以下表格的行数据来源于 servlet 中存储的数据  -->
								<!-- 在jsp中可以编码java代码叫做java小脚本 -->
								<%
								List<Dictionary> list=(List<Dictionary>) request.getAttribute("data");
															
									for(Dictionary d:list){
									%>
										<tr>
											<td><%=d.getDxyname() %></td>
											<td><%=d.getDxiname() %></td>
											<td><%=d.getDzyname() %></td>
											<td><%=d.getDnjname() %></td>
											<td><%=d.getDbjname() %></td>
										</tr>
									<%	
										}
								 %>
<%
for(Dictionary d:list){			
		xyname=xyname+" "+d.getDxyname();				
		xiname=d.getDxiname()+" "+xiname;
		zyname=d.getDzyname()+" "+zyname;
		njname=d.getDnjname()+" "+njname;
		bjname=d.getDbjname()+" "+bjname;
}										
%>
<script type="text/javascript">
//将右侧的两个内容隐藏起来
$(".col-lg-9").children("div:gt(0)").hide();

//希望为左侧的所有的链接增加一个点击的事件
$(".list-group").children("a").click(function() {
	//把之前设置了 选中样式的a的 选中效果去处
	$(".list-group").find(".active").removeClass("active");
	//然后当前点击的是哪一个a就为a增加选中的样式
	$(this).addClass("active");
	//获取当前左侧a的下标值
	var aindex = $(this).index();

	//对应的获取到右侧的div并且显示出来
	$(".col-lg-9").children(":visible").fadeOut(500, function() {
		$(".col-lg-9").children(":eq(" + aindex + ")").fadeIn(500);
	});

});
//向服务器请求老师的数据
	$.ajax({
				     type : "POST", //提交方式
				     dataType:"json",
				     url : "${CTX_PATH}/servlet/GetTeacherDataServlet",//路径
 				     success : function(result) {//返回数据根据结果进行相应的处理
	 			       	$.each(result,function(idx,item){

						   var sex="男";
						   if(item.tsex==0){
						   		sex="女";
						   }

				var rowdata=	" <tr>"+
								"	<td>"+ item.tid +"</td>"+
								"	<td>"+ item.tname +"</td>"+
								"	<td>"+ item.tphone +"</td>"+
								"	<td>"+ sex +"</td>"+
								"</tr>";
							var selectdata="<option value='"+item.tid+"'>"+item.tname+ "</option>";

								$("#teacher_show").append($(rowdata));
								$("#sksd").find("select").append($(selectdata));
								$("#fsxx").find("select").append($(selectdata));
								$("#profile").find("select").append($(selectdata));
						})
	 			     }
	});

//查询出勤记录

$("#queryStartTime").click(function(){
	var teacherid=$("#profile select").find("option:selected").val();
	console.log(teacherid);
	$.ajax({
		type : "POST", //提交方式
	     url : "${CTX_PATH}/servlet/QueryStartTimeServlet",//路径
	     data : { 
	    	 "teacherid":teacherid,
	     },
	     dataType:"json", 
	     success : function(result) {
	    	 console.log(result);
	    	 var iswork;
	    	 
	    		$("#tableStarttime").empty();
	    		$("#tableStarttime").append("<tr >"+
				"<td>"+"上课时间"+"</td>"+
				"<td>"+"考勤状态"+"</td>"+
			"</tr>");
	    		$.each(result, function(idx, obj) {
	    			console.log(obj.stime);
	    		if(obj.iswork!=null)
	    			{
	    			iswork = obj.iswork>0?"正常":"缺勤";
	    			}
	    		else{
	    			iswork = "请假"
	    		}
	    			var rowdata=
	    				"<tr>"+
	    	 		"<td>"+obj.stime+"</td>"+
	    	 		
	    	 		"<td>"+iswork+"</td>"+   
	    	 	
				"</tr>";
				$("#tableStarttime").append(rowdata);
	    		});
	     }
	})
})
</script>
</body>
</html>